package com.venueproject.service.impl;

import com.venueproject.mapper.VenueMapper;
import com.venueproject.pojo.Account;
import com.venueproject.pojo.PageBean;
import com.venueproject.pojo.Venue;
import com.venueproject.service.VenueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VenueServicelmpl implements VenueService {


    @Autowired
    private VenueMapper venueMapper;


    /**
     * 登录
     * @param username
     * @param password
     * @return
     */
    public Account entry(String username, String password) {
        return venueMapper.entry(username,password);
    }

    /**
     * 改变场地状态
     * @param id
     */
    public void Changestatus(int id) {
        venueMapper.changStatus(id);
    }

    /**
     * 场地查询
     * @param page
     * @param pageSize
     * @param number
     * @param name
     * @return
     */
    public PageBean page(Integer page, Integer pageSize, String number, String name) {

        //1.获取总记录数
        Long count = venueMapper.count(number,name);

        //2.获取分页查询结果列表
        Integer start = (page - 1) * pageSize;
        List<Venue> venueList = venueMapper.page(start,pageSize,number,name);

        //3.封装PageBean对象
        PageBean pageBean = new PageBean(count,venueList);
        return pageBean;

    }

    /**
     * 更新场地
     * @param venue
     */
    public void update(Venue venue) {
        venueMapper.update(venue);
    }

    /**
     * 删除场地
     * @param id
     */
    public void DeleteByid(int id) {
        venueMapper.DeleteByid(id);
    }

    /**
     * 添加场地
     * @param venue
     */
    public void Addvenue(Venue venue) {
        venueMapper.add(venue);
    }


}
